<?php

use Illuminate\Database\Seeder;
use App\Models\User;
use Illuminate\Support\Facades\DB;
use App\Models\Role;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        $users = factory(User::class)
            ->times(2)
            ->make();
        $user_array = $users->makeVisible(['password', 'remember_token'])->toArray();
        User::insert($user_array);

        Role::create(
            ['name'=>'管理部门']
        );
        Role::create(
            ['name'=>'超级管理员','parent_id'=>1,'is_role'=>1]
        );

        // 单独处理第一个用户的数据
        $user = User::find(1);
        $user->name = 'admin';
        $user->section_id = 1;
        $user->role_id =2;
        $user->save();

        $user = User::find(2);
        $user->name = 'admin123';
        $user->save();

    }
}
